/**
 * @author: ZhongXu
 * @date:2017-06-22
 */
$(document).ready(
				function() {
					var VAL = {
						NORMAL : "0000000",
						T_FPPFORCEIN : "FPPFORCEIN",
						T_FBPSWHPTH : "FBPSWHPTH",
						T_FBPLSTDAT : "FBPBISDAT",
						T_FIPINQBOX : "FIPINQBOX",
						T_FBPBISPTH : "FBPBISPTH",
						// EVT_USER :$("#userId").text(),
						EVT_USER    :"C1706004",
						DISABLED_ATTR : {
							'disabled' : true
						},
						ENABLED_ATTR : {
							'disabled' : false
						}
					};
					var domObj = {
						$boxIdFk : $("#boxIdFk"),
						$frPathIdFk : $("#frPathIdFk"),
						$boxId : $("#boxId"),
						$boxStat : $("#boxStat"),
						$prdQty : $("#prdQty"),
						$chipQty : $("#chipQty"),
						$crPathIdFk : $("#crPathIdFk"),
						$crPathVerFk : $("#crPathVerFk"),
						$crOpeNoFk : $("#crOpeNoFk"),
						$nxPathIdFk : $("#nxPathIdFk"),
						$nxPathVerFk : $("#nxPathVerFk"),
						$nxOpeNoFk : $("#nxOpeNoFk"),
						$acRecipeId : $("#acRecipeId"),
						$woIdFk : $("#woIdFk"),
						buttons : {
							$query_btn : $("#query_btn"),
							$selectReason_btn : $("#selectReason_btn"),
							$deleteReason_btn : $("#deleteReason_btn"),
							$reWork_btn : $("#reWork_btn"),
							$delReWork_btn : $("#delReWork_btn"),
							$forceReWork_btn : $("#forceReWork_btn"),
						    $stopReWork_btn : $("#stopReWork_btn"),
						},
						grids : {
							$reasonListGrd : $("#reasonListGrd"),
							$reasonListDiv : $("#reasonListDiv"),
							$reasonListPg : $("#reasonListPg"),

							$glassListGrd : $("#glassListGrd"),
							$glassListDiv : $("#glassListDiv"),
							$glassListPg : $("#glassListPg")
						},dialogs : {
							$addReasonDialog : $("#addReasonDialog"),
							$rePathDialog : $("#rePathDialog"),

							$deptId : $("#deptId"),

							$modalReasonListDiv : $("#modalReasonListDiv"),
							$modalReasonListGrd : $("#modalReasonListGrd"),
							$modalReasonListPg : $("#modalReasonListPg"),

							$reModalReasonListDiv : $("#reModalReasonListDiv"),
							$reModalReasonListGrd : $("#reModalReasonListGrd"),
							$reModalReasonListPg : $("#reModalReasonListPg"),

							// 对话框的确认按钮
							$reasonDialog_sureBtn : $("#reasonDialog_sureBtn"),
							$rePathDialog_sureBtn : $("#rePathDialog_sureBtn"),

							$rePathListDiv : $("#rePathListDiv"),
							$rePathListGrd : $("#rePathListGrd"),
							$rePathListPg : $("#rePathListPg"),

						}
						
					}

					var btnFunc = {
						queryBtnfunc : function() {
							clearDataAction();
							var boxIdFk, iary, inObj, outObj;
							boxIdFk = domObj.$boxIdFk.val();// 卡匣id
							if ("" == boxIdFk) {
								showErrorDialog("", "卡匣代码不能为空，请输入卡匣代码");
								return false;
							}
							iary = {
								box_id : boxIdFk
							};
							inObj = {
								trx_id : VAL.T_FIPINQBOX,
								action_flg : "Q",
								box_id : boxIdFk,
								iary : [ iary ]
							};
							outObj = comTrxSubSendPostJson(inObj);
							if (outObj.rtn_code === VAL.NORMAL) {
								if(outObj.box_stat!='WAIT'){
									showErrorDialog("", "该卡匣不是WAIT状态");
									return false;
								}
								var chip_qty;//计算面板数量
								chip_qty=(outObj.prd_qty)*(outObj.oary[0].prd_qty);
								// 初始化卡匣信息
								domObj.$boxId.val(outObj.box_id);
								domObj.$boxStat.val(outObj.box_stat);
								domObj.$prdQty.val(outObj.prd_qty);
								domObj.$chipQty.val(chip_qty);
								domObj.$crPathIdFk
									.val(outObj.oary[0].cr_path_id_fk);
								domObj.$crPathVerFk
									.val(outObj.oary[0].cr_path_ver_fk);
								domObj.$crOpeNoFk
									.val(outObj.oary[0].cr_ope_no_fk);
								domObj.$nxPathIdFk.val(outObj.nx_path_id_fk);
								domObj.$nxPathVerFk.val(outObj.nx_path_ver_fk);
								domObj.$nxOpeNoFk.val(outObj.nx_ope_no_fk);
								domObj.$acRecipeId
									.val(outObj.oary[0].ac_recipe_id);
								domObj.$woIdFk
									.val(outObj.wo_id_fk);
								// 初始化玻璃信息
								setGridInfo(outObj.oary, "#glassListGrd");
								// 初始化重工代码
								var frPathIdFk, frPathVerFk, frOpeNoFk, iarys, inObjs, outObjs;
								frPathIdFk  = outObj.oary[0].cr_path_id_fk;
								frPathVerFk = outObj.oary[0].cr_path_ver_fk;
								frOpeNoFk   = outObj.oary[0].cr_ope_no_fk;
								iarys = {
									fr_path_id_fk : frPathIdFk,
									fr_path_ver_fk : frPathVerFk,
									fr_ope_no_fk : frOpeNoFk,
									swh_typ : "K"
								};
								inObjs = {
									trx_id : VAL.T_FBPSWHPTH,
									action_flg : "Q",
									iary : [ iarys ]								};
								outObjs = comTrxSubSendPostJson(inObjs);
								if (outObjs.rtn_code === VAL.NORMAL) {
									setGridInfo(outObjs.oary, "#rePathListGrd");
								}
															
							}
						},
						selectReasonBtnfunc : function() {
							domObj.dialogs.$modalReasonListGrd
									.jqGrid("clearGridData");
							domObj.dialogs.$reModalReasonListGrd
									.jqGrid("clearGridData");
							// 原因代码对话框的模型
							domObj.dialogs.$addReasonDialog.modal({
								backdrop : true,
								keyboard : false,
								show : false
							});
							domObj.dialogs.$addReasonDialog.modal("show");
							var iary, inObj, outObj;
							iary = {
								data_cate : "DEPT"
							};
							inObj = {
								trx_id : VAL.T_FBPLSTDAT,
								action_flg : "Q",
								iary : [ iary ]
							};
							outObj = comTrxSubSendPostJson(inObj);
							if (outObj.rtn_code === VAL.NORMAL) {
								tblCnt = outObj.tbl_cnt;
								SelectDom.initWithSpace(domObj.dialogs.$deptId);
								var warp = document.createDocumentFragment();
								for (i = 0; i < tblCnt; i++) {
									oary = tblCnt > 1 ? outObj.oary[i]
											: outObj.oary;
									var option = document
											.createElement("option");
									option.value = oary.data_id;
									option.text = oary.data_id;
									warp.appendChild(option);
								}
								domObj.dialogs.$deptId.append(warp);
							}
							// 选中部门代码的事件
							domObj.dialogs.$deptId.on("select2:select",function(e) {
								var deptId, iary, inObj, outObj;
								deptId = domObj.dialogs.$deptId.val();
									iary = {
											data_cate : "RKRS",
											data_ext : deptId
									};
									inObj = {
											trx_id : VAL.T_FBPLSTDAT,
											action_flg : "Q",
											iary : [ iary ]
									};
									outObj = comTrxSubSendPostJson(inObj);
									if (outObj.rtn_code === VAL.NORMAL) {
										var deptIds = domObj.dialogs.$deptId.val();
										var oary = [];
								        for (var i = 0; i < outObj.oary.length; i++) {
											 var reason = {};
											 reason.deptId = deptIds;
											 reason.data_id = outObj.oary[i].data_id;
											 reason.data_desc = outObj.oary[i].data_desc;
											 oary.push(reason);
										}
										setGridInfo(oary,"#modalReasonListGrd");
									}
							});
						},
						deleteReasonBtnfunc : function() {
							var selRowId = domObj.grids.$reasonListGrd.jqGrid(
									"getGridParam", "selrow");
							if (selRowId.length < 1) {
								showErrorDialog("", "请至少选择一条原因代码进行删除");
							}
							$("#deleteReason_btn").showCallBackWarnningDialog(
								{
									errMsg : "是否删选原因代码,请确认!!!!",
									callbackFn : function(data) {
									if (data.result == true) {
									  // 动态删除jqgrid行时，数据会在动态变化
									  var length = selRowId.length;
									  for (var i = 0; i < length; i++) {
									    domObj.grids.$reasonListGrd.jqGrid("delRowData",selRowId[0]);
								      }
								   }
							    }
						    });
						},
						reWorkBtnfunc: function() {
							var boxId,crPathIdFk, crPathVerFk,crOpeNoFk,
								swhId,swhTyp,swhPathIdFk,swhPathVerk,evtUsr,
								outPathIdFk,outPathVerFk,outOpeNoFk,rsnCate,rsnCode,rsnDept,iary,inObj,outObj;
							var reasonRowData =domObj.grids.$reasonListGrd.jqGrid("getRowData");
							if(reasonRowData.length<1){
								showErrorDialog("", "原因代码不能为空");
								return;
							}
							var rowId= domObj.dialogs.$rePathListGrd.jqGrid("getGridParam", "selrow");
							var pathRowData = domObj.dialogs.$rePathListGrd.jqGrid("getRowData",rowId);
							if(rowId==null){
								showErrorDialog("", "重工代码不能为空");
								return;
							}
							var iarys,inObjs,outObjs;//查询在不在主途程上
							iaryA = {
								path_id : domObj.$nxPathIdFk.val(),
								path_ver : domObj.$nxPathVerFk.val()
							};
							inObjs = {
								trx_id : VAL.T_FBPBISPTH,
								action_flg : "Q",
								iaryA : [ iaryA ]
							};
							outObjs = comTrxSubSendPostJson(inObjs);
							if (outObjs.rtn_code === VAL.NORMAL) {
								if(outObjs.oaryA[0].path_cate!='MAIN'){
									showErrorDialog("", "该卡匣不在主流程上，无法进行重工操作");
									return false;
								}
							}
							var rowIds = domObj.grids.$glassListGrd.jqGrid("getGridParam","selarrrow");
							var data = new Array();
							for (var i=0;i<rowIds.length;i++){
								var rowData = domObj.grids.$glassListGrd.jqGrid("getRowData",rowIds[i]);
								data.push(rowData)
							}
							if (data.length<1) {
								showErrorDialog("", "至少选中一条玻璃信息");
								return false;
							}
							boxId = domObj.$boxIdFk.val();
							if (!boxId) {
								showErrorDialog("", "卡匣代码不能为空");
								return false;
							}
							swhId = pathRowData.swh_id;
							if (!swhId) {
								showErrorDialog("", "分支代码不能为空");
								return false;
							}
							swhTyp="K";
							swhPathIdFk=pathRowData.swh_path_id_fk;
							if (!swhPathIdFk) {
								showErrorDialog("", "分支工艺名称不能为空");
								return false;
							}
							swhPathVerk=pathRowData.swh_path_ver_fk;
							if (!swhPathVerk) {
								showErrorDialog("", "分支工艺路线不能为空");
								return false;
							}
							rsnCode = reasonRowData[0].deptId;
							if (!rsnCode) {
								showErrorDialog("", "部门代码不能为空,请输入");
								return false;
							}
							rsnCate = "RKRS";
							rsnDept = reasonRowData[0].data_id;
							if (!rsnDept) {
								showErrorDialog("", "原因代码不能为空,请输入");
								return false;
							}
							crPathIdFk = domObj.$crPathIdFk.val();
							if (!crPathIdFk) {
								showErrorDialog("", "当前工艺路线不能为空");
								return false;
							}
							crPathVerFk = domObj.$crPathVerFk.val();
							if (!crPathVerFk) {
								showErrorDialog("", "当前工艺版本不能为空");
								return false;
							}
							crOpeNoFk = domObj.$crOpeNoFk.val();
							if (!crOpeNoFk) {
								showErrorDialog("", "当前站点不能为空");
								return false;
							}
							outPathIdFk = pathRowData.out_path_id_fk;
							if (!outPathIdFk) {
								showErrorDialog("", "转出工艺路线不能为空");
								return false;
							}
							outPathVerFk = pathRowData.out_path_ver_fk;
							if (!outPathIdFk) {
								showErrorDialog("", "转出工艺版本不能为空");
								return false;
							}
							outOpeNoFk = pathRowData.out_ope_no_fk;
							if (!outOpeNoFk) {
								showErrorDialog("", "转出站点不能为空");
								return false;
							}
							if (!VAL.EVT_USER) {
								showErrorDialog("", "操作人信息不能为空");
								return false;
							}
							iary = {
								box_id : boxId,
								swh_id : swhId,
								swh_typ: swhTyp,
								swh_path_id_fk  : swhPathIdFk,
								swh_path_ver_fk : swhPathVerk,
								rsn_code       : rsnCode,
								rsn_cate       : rsnCate,
								rsn_dept       : rsnDept,
								cr_path_id_fk  : crPathIdFk,
								cr_path_ver_fk : crPathVerFk,
								cr_ope_no_fk   : crOpeNoFk,
								out_path_id_fk  : outPathIdFk,
								out_path_ver_fk : outPathVerFk,
								out_ope_no_fk   : outOpeNoFk,
								ret_prd_info   : data,
								evt_usr        : VAL.EVT_USER,
							};
							inObj = {
								trx_id : VAL.T_FPPFORCEIN,
								action_flg : "R",
								iary : [iary]
							};
							outObj = comTrxSubSendPostJson(inObj);
							if (outObj.rtn_code === VAL.NORMAL) {
								showSuccessDialog("进入重工成功");
								btnFunc.queryBtnfunc();//更新信息
							}
							
						},
						delReWorkBtnfunc : function() {
							var boxId,swhTyp,nxPathIdFk,nxPathVerFk,nxOpeNoFk,crPathIdFk, crPathVerFk,crOpeNoFk,rsnCode,rsnCate,rsnDept,iary,inObj,outObj;
							var reasonRowData =domObj.grids.$reasonListGrd.jqGrid("getRowData");
							if(reasonRowData.length<1){
								showErrorDialog("", "原因代码不能为空");
								return;
							}
							boxId = domObj.$boxIdFk.val();
							swhTyp="K";
							nxPathIdFk = domObj.$nxPathIdFk.val();
							nxPathVerFk = domObj.$nxPathVerFk.val();
							nxOpeNoFk = domObj.$nxOpeNoFk.val();
							crPathIdFk = domObj.$crPathIdFk.val();
							crPathVerFk = domObj.$crPathVerFk.val();
							crOpeNoFk = domObj.$crOpeNoFk.val();
							rsnCode = reasonRowData[0].deptId;
							rsnCate = "RKRS";
							rsnDept = reasonRowData[0].data_id;
							if (!crPathIdFk) {
								showErrorDialog("", "当前工艺路线不能为空");
								return false;
							}
							if (!crPathVerFk) {
								showErrorDialog("", "当前工艺版本不能为空");
								return false;
							}
							if (!crOpeNoFk) {
								showErrorDialog("", "当前站点不能为空");
								return false;
							}
							if (! boxId) {
								showErrorDialog("", "卡匣代码不能为空");
								return false;
							}
							if (!nxPathIdFk) {
								showErrorDialog("", "下一站工艺路线不能为空");
								return false;
							}
							if (!nxPathIdFk) {
								showErrorDialog("", "下一站工艺版本不能为空");
								return false;
							}
							if (!nxOpeNoFk) {
								showErrorDialog("", "下一站站点不能为空");
								return false;
							}
							if (!rsnCode) {
								showErrorDialog("", "部门代码不能为空,请输入");
								return false;
							}
							if (!rsnDept) {
								showErrorDialog("", "原因代码不能为空,请输入");
								return false;
							}
							iary = {
								box_id : boxId,
								swh_typ: swhTyp,
								nx_path_id_fk  : nxPathIdFk,
								nx_path_ver_fk : nxPathVerFk,
								nx_ope_no_fk   : nxOpeNoFk,
								cr_path_id_fk  : crPathIdFk,
								cr_path_ver_fk : crPathVerFk,
								cr_ope_no_fk   : crOpeNoFk,
								rsn_code       : rsnCode,
								rsn_cate       : rsnCate,
								rsn_dept       : rsnDept,
								evt_usr        : VAL.EVT_USER
							};
							inObj = {
								trx_id : VAL.T_FPPFORCEIN,
								action_flg : "C",
								iary : [iary]
							};
							outObj = comTrxSubSendPostJson(inObj);
							if (outObj.rtn_code === VAL.NORMAL) {
								showSuccessDialog("取消重工成功");
								btnFunc.queryBtnfunc();//更新信息
							}
						},
						forceReWorkBtnfunc :function() {
							var boxId,crPathIdFk, crPathVerFk,crOpeNoFk,
								swhId,swhTyp,swhPathIdFk,swhPathVerk,evtUsr,
								outPathIdFk,outPathVerFk,outOpeNoFk,rsnCate,rsnCode,rsnDept,iary,inObj,outObj;
							var reasonRowData =domObj.grids.$reasonListGrd.jqGrid("getRowData");
							if(reasonRowData.length<1){
								showErrorDialog("", "原因代码不能为空");
								return;
							}
							var rowId= domObj.dialogs.$rePathListGrd.jqGrid("getGridParam", "selrow");
							var pathRowData = domObj.dialogs.$rePathListGrd.jqGrid("getRowData",rowId);
							if(rowId==null){
								showErrorDialog("", "重工代码不能为空");
								return;
							}
							var iarys,inObjs,outObjs;//查询在不在主途程上
							iaryA = {
								path_id : domObj.$nxPathIdFk.val(),
								path_ver : domObj.$nxPathVerFk.val()
							};
							inObjs = {
								trx_id : VAL.T_FBPBISPTH,
								action_flg : "Q",
								iaryA : [ iaryA ]
							};
							outObjs = comTrxSubSendPostJson(inObjs);
							if (outObjs.rtn_code === VAL.NORMAL) {
								if(outObjs.oaryA[0].path_cate!='MAIN'){
									showErrorDialog("", "该卡匣不在主流程上，无法进行修补操作");
									return false;
								}
							}
							var rowIds = domObj.grids.$glassListGrd.jqGrid("getGridParam","selarrrow");
							var data = new Array();
							for (var i=0;i<rowIds.length;i++){
								var rowData = domObj.grids.$glassListGrd.jqGrid("getRowData",rowIds[i]);
								data.push(rowData)
							}
							if (data.length<1) {
								showErrorDialog("", "至少选中一条玻璃信息");
								return false;
							}
							boxId = domObj.$boxIdFk.val();
							if (!boxId) {
								showErrorDialog("", "卡匣代码不能为空");
								return false;
							}
							swhId = pathRowData.swh_id;
							if (!swhId) {
								showErrorDialog("", "分支代码不能为空");
								return false;
							}
							swhTyp="K";
							swhPathIdFk=pathRowData.swh_path_id_fk;
							if (!swhPathIdFk) {
								showErrorDialog("", "分支工艺名称不能为空");
								return false;
							}
							swhPathVerk=pathRowData.swh_path_ver_fk;
							if (!swhPathVerk) {
								showErrorDialog("", "分支工艺路线不能为空");
								return false;
							}
							rsnCode = reasonRowData[0].deptId;
							if (!rsnCode) {
								showErrorDialog("", "部门代码不能为空,请输入");
								return false;
							}
							rsnCate = "RKRS";
							rsnDept = reasonRowData[0].data_id;
							if (!rsnDept) {
								showErrorDialog("", "原因代码不能为空,请输入");
								return false;
							}
							crPathIdFk = domObj.$crPathIdFk.val();
							if (!crPathIdFk) {
								showErrorDialog("", "当前工艺路线不能为空");
								return false;
							}
							crPathVerFk = domObj.$crPathVerFk.val();
							if (!crPathVerFk) {
								showErrorDialog("", "当前工艺版本不能为空");
								return false;
							}
							crOpeNoFk = domObj.$crOpeNoFk.val();
							if (!crOpeNoFk) {
								showErrorDialog("", "当前站点不能为空");
								return false;
							}
							outPathIdFk = pathRowData.out_path_id_fk;
							if (!outPathIdFk) {
								showErrorDialog("", "转出工艺路线不能为空");
								return false;
							}
							outPathVerFk = pathRowData.out_path_ver_fk;
							if (!outPathIdFk) {
								showErrorDialog("", "转出工艺版本不能为空");
								return false;
							}
							outOpeNoFk = pathRowData.out_ope_no_fk;
							if (!outOpeNoFk) {
								showErrorDialog("", "转出站点不能为空");
								return false;
							}
							if (!VAL.EVT_USER) {
								showErrorDialog("", "操作人信息不能为空");
								return false;
							}
							iary = {
								box_id : boxId,
								swh_id : swhId,
								swh_typ: swhTyp,
								swh_path_id_fk  : swhPathIdFk,
								swh_path_ver_fk : swhPathVerk,
								rsn_code       : rsnCode,
								rsn_cate       : rsnCate,
								rsn_dept       : rsnDept,
								cr_path_id_fk  : crPathIdFk,
								cr_path_ver_fk : crPathVerFk,
								cr_ope_no_fk   : crOpeNoFk,
								out_path_id_fk  : outPathIdFk,
								out_path_ver_fk : outPathVerFk,
								out_ope_no_fk   : outOpeNoFk,
								ret_prd_info   : data,
								evt_usr        : VAL.EVT_USER,
							};
							inObj = {
								trx_id : VAL.T_FPPFORCEIN,
								action_flg : "F",
								iary : [iary]
							};
							outObj = comTrxSubSendPostJson(inObj);
							if (outObj.rtn_code === VAL.NORMAL) {
								showSuccessDialog("强制进入重工成功");
								btnFunc.queryBtnfunc();//更新信息
							}
						},
						  stopReWorkBtnfunc : function() {
							  var boxId,swhTyp, crPathIdFk,crPathVerFk,crOpeNoFk,rsnCode,rsnCate,rsnDept,iary,inObj,outObj;
							  var reasonRowData =domObj.grids.$reasonListGrd.jqGrid("getRowData");
							  if(reasonRowData.length<1){
								  showErrorDialog("", "原因代码不能为空");
								  return;
							  }
							  boxId = domObj.$boxIdFk.val();
							  swhTyp="K"
							  crPathIdFk = domObj.$crPathIdFk.val();
							  crPathVerFk = domObj.$crPathVerFk.val();
							  crOpeNoFk = domObj.$crOpeNoFk.val();
							  rsnCode = reasonRowData[0].deptId;
							  rsnCate = "RKRS";
							  rsnDept = reasonRowData[0].data_id;
							  if (! boxId) {
								  showErrorDialog("", "卡匣代码不能为空");
								  return false;
							  }
							  if (!rsnCode) {
								  showErrorDialog("", "部门代码不能为空,请输入");
								  return false;
							  }
							  if (!rsnDept) {
								  showErrorDialog("", "原因代码不能为空,请输入");
								  return false;
							  }
							  evtUsr=VAL.EVT_USER;
							  if (!evtUsr) {
								  showErrorDialog("", "操作人信息不能为空,请输入");
								  return false;
							  }
							  iary = {
								  box_id    : boxId,
								  swh_typ   : swhTyp,
								  cr_path_id_fk  : crPathIdFk,
								  cr_path_ver_fk : crPathVerFk,
								  cr_ope_no_fk   : crOpeNoFk,
								  rsn_code  : rsnCode,
								  rsn_cate  : rsnCate,
								  rsn_dept  : rsnDept,
								  evtUsr    : evtUsr,
							  };
							  inObj = {
								  trx_id : VAL.T_FPPFORCEIN,
								  action_flg : "A",
								  iary : [iary]
							  };
							  outObj = comTrxSubSendPostJson(inObj);
							  if (outObj.rtn_code === VAL.NORMAL) {
								  showSuccessDialog("终止重工成功");
								  btnFunc.queryBtnfunc();//更新信息
							  }
						  }
					}
					// 主页面grid初始化
					var iniGridInfo = function() {
						domObj.grids.$reasonListGrd.jqGrid({
							url : "",
							datatype : "local",
							mtype : "POST",
							height : 100,
							width : domObj.grids.$reasonListDiv.width(),
							autowidth : false,
							shrinkToFit : false,
							resizable : true,
							loadonce : true,
							viewrecords : true,
							rownumbers : true,
							rowNum : 20,
							emptyrecords : true,
							multiselect : false,
							pager : domObj.grids.$reasonListPg,
							colModel : [ {
								name : 'deptId',
								index : 'deptId',
								label : '部门代码',
								width : 250
							}, {
								name : 'data_id',
								index : 'data_id',
								label : '原因代码',
								width : 250
							}, {
								name : 'data_desc',
								index : 'data_desc',
								label : '原因代码说明',
								width : 450
							},]
						});

						domObj.grids.$glassListGrd.jqGrid({
							url : "",
							datatype : "local",
							mtype : "POST",
							height : 360,
							width : domObj.grids.$glassListDiv.width(),
							autowidth : false,
							shrinkToFit : false,
							resizable : true,
							loadonce : true,
							viewrecords : true,
							rownumbers : true,
							rowNum : 20,
							emptyrecords : true,
							multiselect : true,
							pager : domObj.grids.$glassListPg,
							colModel : [ {
								name : 'prd_seq_id',
								index : 'prd_seq_id',
								label : '玻璃代码',
								width : 150
							}, {
								name : 'slot_no',
								index : 'slot_no',
								label : '子格位',
								width : 150
							}, {
								name : 'prd_stat',
								index : 'prd_stat',
								label : '玻璃状态',
								width : 115
							}, {
								name : 'prd_qty',
								index : 'prd_qty',
								label : '面板数量',
								width : 115
							}, {
								name : 'box_id_fk',
								index : 'box_id_fk',
								label : '卡匣代码',
								width : 150
							}, {
								name : 'prd_grade',
								index : 'prd_grade',
								label : '大板等级',
								width : 115
							}, {
								name : 'wo_id_fk',
								index : 'wo_id_fk',
								label : '工单信息',
								width : 150
							}]
						});
					}
					// 重工代码dailog对话框grid初始化
					var inModelGrid = function() {
						domObj.dialogs.$modalReasonListGrd
								.jqGrid("clearGridData");
						domObj.dialogs.$reModalReasonListGrd
								.jqGrid("clearGridData");
						domObj.dialogs.$rePathListGrd.jqGrid({
							url : "",
							datatype : "local",
							mtype : "POST",
							height : 400,
							// width:domObj.dialogs.rePathListDiv.width()* 0.99,
							width : 650,
							autowidth : false,
							shrinkToFit : false,
							resizable : true,
							loadonce : true,
							viewrecords : true,
							rownumbers : true,
							rowNum : 20,
							emptyrecords : true,
							multiselect : false,
							pager : domObj.dialogs.$rePathListPg,
							colModel : [{
								name : 'swh_id',
								index : 'swh_id',
								label : '分支号码',
								width : 100
							}, {
								name : 'swh_path_id_fk',
								index : 'swh_path_id_fk',
								label : '分支工艺名称',
								width : 100
							}, {
								name : 'swh_path_ver_fk',
								index : 'swh_path_ver_fk',
								label : '分支工艺路线版本',
								width : 100
							}, {
								name : 'out_path_id_fk',
								index : 'out_path_id_fk',
								label : '转出工艺路线名称',
								width : 100
							}, {
								name : 'out_path_ver_fk',
								index : 'out_path_ver_fk',
								label : '转出工艺路线版本',
								width : 100
							}, {
								name : 'out_ope_no_fk',
								index : 'out_ope_no_fk',
								label : '转出工艺站点代码',
								width : 100
							} ],
						});
						domObj.dialogs.$modalReasonListGrd
								.jqGrid({
									url : "",
									datatype : "local",
									mtype : "POST",
									height : 300,
									// width :
									// domObj.dialogs.$modalReasonListDiv.width()*0.99,
									width : 400,
									autowidth : false,
									shrinkToFit : false,
									resizable : true,
									loadonce : true,
									viewrecords : true,
									rownumbers : true,
									rowNum : 20,
									emptyrecords : true,
									multiselect : false,
									pager : domObj.dialogs.$modalReasonListPg,
									colModel : [ {
										name : 'deptId',
										index : 'deptId',
										label : '部门代码',
										hidden : true,
										width : 100
									}, {
										name : 'data_id',
										index : 'data_id',
										label : '原因代码',
										width : 150
									}, {
										name : 'data_desc',
										index : 'data_desc',
										label : '原因代码说明',
										width : 180
									} ],
									onSelectRow : function(rowId, status) {
										var rowId= domObj.dialogs.$modalReasonListGrd
										.jqGrid("getGridParam", "selrow");
										rowData = domObj.dialogs.$modalReasonListGrd.jqGrid(
												"getRowData", rowId);
										setGridInfo(rowData, "#reModalReasonListGrd");
									}						
								});

						domObj.dialogs.$reModalReasonListGrd.jqGrid({
							url : "",
							datatype : "local",
							mtype : "POST",
							height : 400,
							// width:domObj.dialogs.$reModalReasonListDiv.width()*
							// 0.99,
							width : 400,
							autowidth : false,
							shrinkToFit : false,
							resizable : true,
							loadonce : true,
							viewrecords : true,
							rownumbers : true,
							rowNum : 20,
							emptyrecords : true,
							multiselect  : false,
							pager : domObj.dialogs.$reModalReasonListPg,
							colModel : [ {
								name : 'deptId',
								index : 'deptId',
								label : '部门代码',
								width : 100
							}, {
								name : 'data_id',
								index : 'data_id',
								label : '原因代码',
								width : 100
							}, {
								name : 'data_desc',
								index : 'data_desc',
								label : '原因代码说明',
								width : 100,
							} ]
						});						
					}
					// 选中重工代码的事件
					domObj.$frPathIdFk.on("select2:opening",function(e) {
						 domObj.dialogs.$rePathDialog.modal({
						   backdrop : true,
						   keyboard : false,
						   show : false
					     });
						domObj.dialogs.$rePathDialog.modal("show");
				    });
					var dialogFnc = {
							  reasonSureFnc : function() {
								       var Data = domObj.dialogs.$reModalReasonListGrd.jqGrid("getRowData");
										if(Data.length<1){									
											showErrorDialog("", "请选择一条原因代码");
											return false;	
										}
										setGridInfo(Data, "#reasonListGrd");
										domObj.dialogs.$addReasonDialog.modal("hide");
									},
							  rePathSureFnc : function() {
										var rowId= domObj.dialogs.$rePathListGrd
										.jqGrid("getGridParam", "selrow");
										if(rowId==null){									
											showErrorDialog("", "请选择一条重工代码");
											return false;	
										}
										rowData = domObj.dialogs.$rePathListGrd.jqGrid(
												"getRowData", rowId);
										SelectDom.setSelect(domObj.$frPathIdFk,
												rowData.swh_id);
										domObj.dialogs.$rePathDialog.modal("hide");
							        }
						      }
								
					var iniButtonAction = function() {
						domObj.buttons.$query_btn.click(function() {
							btnFunc.queryBtnfunc();
						});
						// 确认按钮绑定click事件函数
						domObj.dialogs.$rePathDialog_sureBtn.bind('click',
								dialogFnc.rePathSureFnc);
						domObj.buttons.$selectReason_btn.click(function() {
							btnFunc.selectReasonBtnfunc();
						});
						domObj.buttons.$deleteReason_btn.click(function() {
							btnFunc.deleteReasonBtnfunc();
						});
						// 确认按钮绑定click事件函数
						domObj.dialogs.$reasonDialog_sureBtn.bind('click',
								dialogFnc.reasonSureFnc);
						domObj.buttons.$delReWork_btn.click(function() {
							btnFunc.delReWorkBtnfunc();
						});
						domObj.buttons.$forceReWork_btn.click(function() {
							btnFunc.forceReWorkBtnfunc();
						});	
						domObj.buttons.$reWork_btn.click(function() {
							btnFunc.reWorkBtnfunc();
						});
						domObj.buttons.$stopReWork_btn.click(function() {
							btnFunc.stopReWorkBtnfunc();
						});
					}
					var clearDataAction = function() {
						SelectDom.setSelect(domObj.$frPathIdFk,"");
						domObj.$boxId.val("");
						domObj.$boxStat.val("");
						domObj.$prdQty.val("");
						domObj.$chipQty.val("");
						domObj.$crPathIdFk.val("");
						domObj.$crPathVerFk.val("");
						domObj.$crOpeNoFk.val("");
						domObj.$nxPathIdFk.val("");
						domObj.$nxPathVerFk.val("");
						domObj.$nxOpeNoFk.val("");
						domObj.$acRecipeId.val("");
						domObj.$woIdFk.val("");
						$("#reasonListGrd").jqGrid('clearGridData');
						$("#glassListGrd").jqGrid('clearGridData');
						$("#modalReasonListDiv").jqGrid('clearGridData');
						$("#reModalReasonListDiv").jqGrid('clearGridData');
						$("#rePathListDiv").jqGrid('clearGridData');
					}
					var otherActionBind = function(){
						//Stop from auto commit
						$("form").submit(function(){
							return false;
						});

					};

					domObj.$boxIdFk.keydown(function(event) {
						if (event.which == 13) {
							btnFunc.queryBtnfunc();
						}
					});
					function initFunc() {
						domObj.$boxIdFk.val("");
						SelectDom.setSelect(domObj.frPathIdFk);
						iniGridInfo();
						iniButtonAction();
						inModelGrid();// 初始化dailog中的grids
						otherActionBind();
					}
					initFunc();
				})